import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersistence from 'vuex-persist'
Vue.use(Vuex)
const vuexLocal = new VuexPersistence({
	storage: {
		getItem: key => uni.getStorageSync(key),
		setItem: (key, value) => uni.setStorageSync(key, value),
		removeItem: key => uni.removeStorageSync(key),
		clear: () => uni.clearStorageSync(),
	}
})
const store = new Vuex.Store({
	plugins: [vuexLocal.plugin],
	state: {
		wechatInfo: {},
		userInfo: {}
	},
	mutations: {
		commitWechatInfo(state, wechatInfo) {
			state.wechatInfo = wechatInfo
		},
	},
	actions: {
		actionWechatInfo: ({
			state,
			commit
		}, opts) => {
			commit('commitWechatInfo', opts)
		}
	}
})

export default store
